<?php

namespace app\models;
use MongoDB\BSON\Timestamp;
use yii\behaviors\TimestampBehavior;

/**
 * This is the model class for table "asr_plan".
 *
 * @property int $plan_id 拨打计划表的自增ID
 * @property string $planname 计划名称
 * @property int $create_at 创建时间
 * @property string $directory 所属的号码本
 * @property int $already_call 已拨打
 * @property int $line_num 线路数目
 * @property string $belong 计划所属
 * @property string $verbal_name 话术名称
 * @property string $classify 分类
 * @property int $state 状态1为正在执行，2为暂停执行，3为执行完成，
 */
class AsrPlan extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'asr_plan';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['plan_id', 'mobile_id', 'audio_id','call_id','plan_space'], 'integer'],
            [['planname'], 'string', 'max' => 30],
            [['planname'], 'required', 'message' => '必填项'],
            [['planname'], 'unique'],
            [['plan_id'], 'unique'],
            [['call_start', 'call_end'], 'string'],
            ['plan_space', 'integer', 'min' => 1, 'integerOnly' => true],
            [['plan_space'], 'required', 'message' => '必填项'],
        ];
    }
    public function behaviors()
    {
        return [
            TimestampBehavior::className()
        ];
    }
    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'planname' => '计划名称',
            'created_at' => '创建时间',
            'line_num' => '线路数目',
            'state' => '执行状态',
            'listname' => '号码本',
            'belong' => '计划所属',
            'audio_name' => '话术名称',
            'name' => '话术分类',
            'plan_space' => '拨打间隔',
            'call_start' => '拨打开始时间',
            'call_end' => '结束时间'
        ];
    }

    /**
     * 关联asr_mobile表
     */
    public function getAsrMobile()
    {
        return $this->hasOne(AsrMobile::className(), ['mobile_id' => 'mobile_id']);
    }
}
